# 导入库
from flask_sqlalchemy import SQLAlchemy
from flask import Flask

app = Flask(__name__)

# 配置信息
class DbConfig(object):
    # 设置连接数据库的url
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/flask_test"
    # 设置每次请求结束后会自动提交数据库中的改动
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    # 可修改
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    # 查询时会显示原始SQL语句
    SQLALCHEMY_ECHO = True
# 初始化配置
app.config.from_object(DbConfig)

if __name__ == '__main__':
    app.run(debug=True)

